package com.gitee.wsl.compose.modifier

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.TransformableState
import androidx.compose.foundation.gestures.transformable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset

interface ModifierTouchScope: ModifierScope {
    fun transformable(
        state: TransformableState,
        lockRotationOnZoomPan: Boolean = false,
        enabled: Boolean = true
    ){
        modifier = modifier.transformable(state, lockRotationOnZoomPan, enabled)
    }

    @OptIn(ExperimentalFoundationApi::class)
    fun transformable(
        state: TransformableState,
        canPan: (Offset) -> Boolean,
        lockRotationOnZoomPan: Boolean = false,
        enabled: Boolean = true
    ){
        modifier = modifier.transformable(state, canPan,lockRotationOnZoomPan, enabled)
    }
}

class ModifierTouchScopeImp(override var modifier: Modifier):ModifierTouchScope

inline fun Modifier.touch(block:ModifierTouchScope.()->Unit): Modifier = ModifierTouchScopeImp(this).apply(block).modifier
